package design.pattern.singleton.demo9;

import java.io.IOException;
import java.io.InputStream;

/**
 * Runtime就是一个典型的饿汉式单例模式类
 * @author AtoVio, Winter Yuan
 */
public class RuntimeDemo {
    public static void main(String[] args) throws IOException {
        // 获取Runtime对象
        Runtime runtime = Runtime.getRuntime();

        // 调用Runtime方法
        Process process = runtime.exec("ipconfig");
        // 调用process的对象来获取输入输出流
        InputStream is = process.getInputStream();
        byte[] arr = new byte[1024 * 1024 * 100];
        // 读取数据
        int len = is.read(arr); // 返回读到的字节的个数
        // 将字节转为字符串输出到控制台
        System.out.println(new String(arr, 0, len, "GBK"));
    }
}
